package com.itgaoshu.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itgaoshu.bean.Jilu;
import com.itgaoshu.mapper.JiluMapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * \* @author: 李豪杰
 * \* Date: 2021/3/21
 * \* Time: 20:32
 * \* Description:
 * \
 */
@Controller
@RequestMapping("record")
public class JiLuController {
    @Resource
    private JiluMapper jiluMapper;
    @RequestMapping("selrecord")
    @ResponseBody
    public Object selectAllJilus(Jilu jilu, Integer page, Integer limit){
        PageHelper.startPage(page, limit);
        List<Jilu> selrecord = jiluMapper.selectAlljillus(jilu);
        PageInfo pageInfo = new PageInfo(selrecord);
        Map<String, Object> drugstoresData = new HashMap<String, Object>();
        //这是layui要求返回的json数据格式
        drugstoresData.put("code", 0);
        drugstoresData.put("msg", "");
        //将全部数据的条数作为count传给前台（一共多少条）
        drugstoresData.put("count", pageInfo.getTotal());
        //将分页后的数据返回（每页要显示的数据）
        drugstoresData.put("data", pageInfo.getList());
        return drugstoresData;
    }
}
